package com.ctgu.rabbitmq.controller;

import com.ctgu.rabbitmq.service.DelayQueueService;
import com.ctgu.rabbitmq.utils.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @ ClassName DelayQueueController
 * @ Author Alex2
 * @ Date 2025/8/15 14:56
 **/
@RestController
@RequestMapping("/api/delayQueue")
public class DelayQueueController {

    @Autowired
    private DelayQueueService delayQueueService;

    /**
     * @ Author: Alex
     * @ Description: 死信队列实现延迟队列
     */
    // http://localhost:8080/api/delayQueue/deadLetterDelayQueue?name=fork&price=2.49&userId=1
    @GetMapping("deadLetterDelayQueue")
    public ApiResult deadLetterDelayQueue(@RequestParam String name, @RequestParam BigDecimal price, @RequestParam Integer userId) {
        return delayQueueService.deadLetterDelayQueue(name, price, userId);
    }

    /**
     * @ Author: Alex
     * @ Description: 延迟插件实现延迟队列
     */
    // http://localhost:8080/api/delayQueue/deadLetterDelayQueue?name=spoon&price=1.99&userId=1
    @GetMapping("delayPlugin")
    public ApiResult delayPlugin(@RequestParam String name, @RequestParam BigDecimal price, @RequestParam Integer userId) {
        return delayQueueService.delayPlugin(name, price, userId);
    }
}
